//
//  PayPickerDataSource.m
//  MoneyBook
//
//  Created by Justin Kim on 11. 6. 28..
//  Copyright 2011 Daum. All rights reserved.
//

#import "PayPickerDataSource.h"
#import "SQLHandler.h"

@implementation PayPickerDataSource

@synthesize payPickerArray = _payPickerArray;

@synthesize payType = _payType;

/////////////////////////////////////////////////////////////////////////////////////////////////
- (id)init{
	self = [super init];
	if (self){
    }
    return self;
}

/////////////////////////////////////////////////////////////////////////////////////////////////
- (void)dealloc{
	[_payPickerArray  release];
    
    [super dealloc];
}

#pragma mark -
#pragma mark UIPickerViewDataSource
/////////////////////////////////////////////////////////////////////////////////////////////////
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{
    //    NSLog(@"numberOfRowsInComponent");
    return [_payPickerArray count];
}

/////////////////////////////////////////////////////////////////////////////////////////////////
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{
    //    NSLog(@"numberOfComponentsInPickerView");
    return 1;
}

/////////////////////////////////////////////////////////////////////////////////////////////////
-(void)reloadData{
    switch (_payType) {
        case PAY_CASH:
            NSLog(@"reload cash");
            self.payPickerArray = [[SQLHandler sharedInstance] findAllCash];
            break;
        case PAY_CARD:
            NSLog(@"reload card");            
            self.payPickerArray = [[SQLHandler sharedInstance] findAllCard];            
            break;
        case PAY_BANK:
            NSLog(@"reload bank");            
            self.payPickerArray = [[SQLHandler sharedInstance] findAllBank];            
            break;
    }
}
@end
